import Vue from 'vue'
import Router from 'vue-router'
import home from '../components/home/index.vue'
import leavemsg from '../components/leavemsg/index.vue'
import article from '../components/article/index.vue'
import updateLog from '../components/updateLog/index.vue'
import about from '../components/about/index.vue'
import login from '../components/login/index.vue'
import regist from '../components/login/regist.vue'
import space from '../components/spcae/index.vue'
import articledetail from '../components/articledetail/articledetail.vue'
import writearticle from '../components/writearticle/index.vue'

Vue.use(Router)

export default new Router({
  mode: 'history',
  base: 'bbs',
  routes: [
    {
      path: '/',
      name: 'home',
      component: home
    }, {
      path: '/article',
      name: 'article',
      component: article
    }, {
      path: '/leavemsg',
      name: 'leavemsg',
      component: leavemsg
    }, {
      path: '/updateLog',
      name: 'updateLog',
      component: updateLog
    }, {
      path: '/about',
      name: 'about',
      component: about
    }, {
      path: '/login',
      name: 'login',
      component: login
    }, {
      path: '/regist',
      name: 'regist',
      component: regist
    }, {
      path: '/space',
      name: 'space',
      component: space
    }, {
      path: '/articledetail/:id',
      name: 'articledetail',
      component: articledetail
    }, {
      path: '/writearticle',
      name: 'writearticle',
      component: writearticle
    }],

  scrollBehavior(to, from, savedPosition) {
    if (savedPosition) {
      return savedPosition
    } else {
      return {
        x: 0,
        y: 0
      }
    }
  }
})